//
//  DetailTableViewCell.m
//  Memo
//
//  Created by A-01 on 2020/7/8.
//  Copyright © 2020 A-01. All rights reserved.
//

#import "DetailTableViewCell.h"

@implementation DetailTableViewCell


- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier{
    
    if ([super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        [self setupUI];
    }
    
    return self;
}


- (void)setupUI{

    self.selectionStyle = UITableViewCellSelectionStyleNone;
    self.backgroundColor = [UIColor clearColor];
    
    UIView * backView = [UIView new];
    
    backView.backgroundColor = ZRWhiteColor;
    
    self.backView = backView;
    
    [self.contentView addSubview:self.backView];
    
    
    UILabel * titleLabel = [UILabel new];
    
    titleLabel.textColor = ZRBlackColor;
    titleLabel.font = [UIFont systemFontOfSize:16];
    
    self.titleLabel = titleLabel;
    
    [self.backView addSubview:self.titleLabel];
    
    
    UILabel * vauleLabel = [UILabel new];
    
    vauleLabel.textColor = [UIColor colorWithHexString:@"999999"];
    vauleLabel.font = [UIFont systemFontOfSize:14];
    vauleLabel.textAlignment = NSTextAlignmentRight;
    
    self.vauleLabel = vauleLabel;
    
    [self.backView addSubview:self.vauleLabel];
    
    
    UIImageView * rightImageView = [UIImageView new];
    
    rightImageView.image = [UIImage imageNamed:@"right"];
    
    self.rightImageView = rightImageView;
    
    [self.contentView addSubview:self.rightImageView];
}


-(void)layoutSubviews{
    
    [self.backView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.leading.mas_equalTo(self.contentView).offset(20);
        make.trailing.mas_equalTo(self.contentView).offset(-20);
        make.centerY.mas_equalTo(self.contentView);
        make.height.mas_equalTo(45);
    }];
    
    [self.titleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.backView);
        make.leading.mas_equalTo(self.backView).offset(15);
    }];
    
    [self.rightImageView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.backView);
        make.trailing.mas_equalTo(self.backView).offset(-15);
        make.width.mas_equalTo(8);
        make.height.mas_equalTo(14);
    }];
    
    [self.vauleLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerY.mas_equalTo(self.backView);
        make.trailing.mas_equalTo(self.rightImageView.mas_leading).offset(-15);
    }];
}

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
